/*
 * escritor.c
 *
 *  Created on: Jun 28, 2009
 *      Author: marduke
 */

#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include <string.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <ctype.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <dirent.h>
#include <pwd.h>
#include <grp.h>
#include <time.h>
#include <signal.h>


main (int argc, char *argv[]) {
 int fd, messagelen,i;
 char message[100];

 sprintf(message, "Hello from PID %d", getpid());
 messagelen = strlen(message) + 1;
 do {
   fd = open("aPipe", O_WRONLY|O_NDELAY);
   if (fd == -1) sleep(1);
 }
 while(fd == -1);

 for (i = 1; i < 4; i++) {
    write(fd, message, messagelen);
    sleep(3);
 }
 close(fd);
}
